<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<div>
			<p>我是段落标签</p>
			<a href="#">我是超链接</a>
		</div>
		<script type="text/javascript">
			// 作业1 原型上编程  hasChildren 判断父元素有没有子元素节点
			var div = document.getElementsByTagName('div')[0];
			
			
			Element.prototype.hasChildren = function(){
				var children = this.childNodes,
					len = children.length,
					item;
					
				for (var i = 0; i < len; i++){
					item = children[i];
					if (item.nodeType === 1){
						return true;
					}
				}
				
				return false;
			}
			
			var result = div.hasChildren();
			console.log(result);
		</script>
	</body>
</html>
